<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:pe="http://primefaces.org/ui/extensions">
    <h:head>
        <title>#{bundle.bilyet}</title>
        <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
    </h:head>
    <h:body>
        <ui:composition>
            
            <h:form>
                
                <script type="text/javascript">  
                    
                    function handleDepositInfo(xhr, status, args) {  
                        if(args.validationFailed || !args.success) {  
                            jQuery('#dialog').effect("shake", { times:3 }, 100);  
                            alert("fail");
                        } else {  
                           dlgDepositInfo.hide();  
                           alert("success");
                        }  
                    }
                    
                    
                    function componenKeyPressDepositInfo(e) {
                    var code = (e.keyCode ? e.keyCode : e.which);
                    if(code==13) {
                        cmdSearchDepositInfo.jq.click();
                        e.preventDefault();
                    }
                    }
                </script>  
                
                <p:outputPanel autoUpdate="true">
                <p:toolbar >
                    <p:toolbarGroup align="left">
                       
                        <p:commandButton value="#{bundle.btnOpen}" icon="ui-icon-disk" 
                                        update=":#{utilityBean.findClientId('displayDepositInfo')}" actionListener="#{depositInfoBean.openData()}"
                                        oncomplete="dlgDepositInfo.show();"> 
                                        <f:param value="#{loginBean.selectedUser.userId}" name="userId" />
                        </p:commandButton>
                      
                        <p:commandButton value="Refresh" icon="ui-icon-search" update=":#{utilityBean.findClientId('dtDepositInfo')}" 
                                         actionListener="#{depositInfoBean.loadSavings()}" >
                            <f:param value="#{loginBean.selectedUser.userId}" name="userId" />
                        </p:commandButton>
                  
                    </p:toolbarGroup>
                     <p:toolbarGroup align="right">
                    <h:panelGrid columns="3" cellpadding="0" cellspacing="0">  
                        <p:inputText size="30" onkeyup="upperCase(this)" id="depositInfoSearch" value="#{depositInfoBean.filter}" onkeypress="componenKeyPressDepositInfo(event)" />  
                        <p:watermark for="depositInfoSearch" value="#{bundle.bilyetNo} or Nama" />  
                        
                        <p:commandButton widgetVar="cmdSearchDepositInfo" icon="ui-icon-search" update="dtDepositInfo" 
                                         actionListener="#{depositInfoBean.search()}" /> 
                    </h:panelGrid>  
                </p:toolbarGroup>
                </p:toolbar>
                </p:outputPanel>
                
                <p:dataTable id="dtDepositInfo" value="#{depositInfoBean.bilyets}" var="approve" 
                             selection="#{depositInfoBean.bilyet}" selectionMode="single" rowKey="#{approve.bilyetId}" 
                    rowIndexVar="noUrut" emptyMessage=""
                    paginator="true" rows="10" paginatorPosition="bottom" 
                    paginatorTemplate="{CurrentPageReport} {PreviousPageLink} {NextPageLink}"
                    resizableColumns="true">
                                        
                    <p:column style="width: 10px">
                        <f:facet name="header">No.</f:facet>
                        <h:outputText value="#{noUrut+1}" />
                    </p:column>
                    
                    <p:column style="width: 90px">
                        <f:facet name="header">#{bundle.bilyetNo}</f:facet>
                        <h:outputText value="#{approve.bilyetNo}" />
                    </p:column>

                <!--    <p:column style="width: 90px" >
                        <f:facet name="header">#{bundle.cif}</f:facet>
                        <h:outputText value="#{approve.customer.cif}" />
                    </p:column>
                    -->                    
                    <p:column style="width: 130px" >
                        <f:facet name="header">#{bundle.customer}</f:facet>
                        <h:outputText value="#{approve.customer.customerName}" />
                    </p:column>
                    <p:column style="width: 230px" >
                        <f:facet name="header">#{bundle.addressId}</f:facet>
                        <h:outputText value="#{approve.customer.idAddressLine1}" />
                    </p:column>
                                        
                    <p:column style="width: 80px" >
                        <f:facet name="header">#{bundle.date}</f:facet>
                        <h:outputText value="#{approve.bilyetDate}" />
                    </p:column>
                     <p:column style="width: 80px" >
                         <f:facet name="header">#{bundle.dueDate}</f:facet>
                        <h:outputText value="#{approve.closeDate}" />
                    </p:column>
                    <p:column style="width: 130px" >
                        <f:facet name="header">#{bundle.interestRate}</f:facet>
                        <h:outputText value="#{approve.interestRate}" styleClass="numPos">
                            <f:convertNumber groupingUsed="true" />
                        </h:outputText>
                    </p:column>
                    <p:column style="width: 130px" >
                        <f:facet name="header">#{bundle.amount}</f:facet>
                        <h:outputText value="#{approve.principleAmount}" styleClass="numPos">
                            <f:convertNumber groupingUsed="true" />
                        </h:outputText>
                    </p:column>
                     <p:column style="width: 130px" >
                         <f:facet name="header">#{bundle.interestAmount}</f:facet>
                        <h:outputText value="#{approve.interestAmount}" styleClass="numPos">
                            <f:convertNumber groupingUsed="true" />
                        </h:outputText>
                    </p:column>
                </p:dataTable>
            </h:form>     
            
            <p:dialog header="Informasi Rekening Deposito" widgetVar="dlgDepositInfo" closable="true" dynamic="true" 
                           appendToBody="true" modal="true" >
                <p:ajax immediate="true" event="close" listener="#{depositInfoBean.handleClose}"/>
                <h:form>       
                    <p:tabView>
                        <p:tab title="Data">
                    <h:panelGrid id="displayDepositInfo" styleClass="addELIT" cellpadding="0" 
                                 style="vertical-align: top" columnClasses="panelGridId,panelGridId">
                        
                        <h:panelGrid columns="2" rowClasses="panelGridId" >
                            <p:panel header="#{bundle.bilyetLedgend}" >
                                <h:panelGrid columns="3" cellpadding="0" cellspacing="5">
                                    <h:outputLabel value= "#{bundle.bilyetNo}" /><h:outputLabel value= ":" />
                                    <h:outputText value="#{depositInfoBean.bilyet.bilyetNo}" />

                                    <h:outputLabel value= "#{bundle.bilyetDate}" /><h:outputLabel value= ":" />
                                    <h:outputText value="#{depositInfoBean.bilyet.bilyetDate}" />

                                    <h:outputLabel value="#{bundle.deproduct}" /><h:outputLabel value= ":" />
                                    <p:selectOneMenu value="#{depositInfoBean.bilyet.deproduct.deproductId}" 
                                                style="width: 202px;" disabled="true">
                                        <f:selectItems value="#{depositInfoBean.avblProd}" />
                                    </p:selectOneMenu>

                                    <h:outputLabel style="padding: 0 15px 0 0;" value= "#{bundle.cif}" /><h:outputLabel value= ":" />
                                    <h:outputText  value="#{depositInfoBean.bilyet.customer.cif}" />

                                    <h:outputLabel value= "#{bundle.aro}" /><h:outputLabel value= ":" />
                                    <p:selectBooleanCheckbox value="#{depositInfoBean.bilyet.aro}" disabled="true"/>

                                    <h:outputLabel value= "#{bundle.parentBilyet}" /><h:outputLabel value= ":" />
                                    <h:outputText value="#{depositInfoBean.bilyetParentNo}" />

                                    <h:outputLabel value= "#{bundle.amount}" /><h:outputLabel value= ":" />
                                    <h:outputText value="#{depositInfoBean.bilyet.principleAmount}" styleClass="numPos">
                                        <f:convertNumber />
                                    </h:outputText> 

                                    <h:outputLabel value="#{bundle.interestRate}" /><h:outputLabel value= ":" />
                                    <h:outputText value="#{depositInfoBean.bilyet.interestRate}" styleClass="numPos">
                                        <f:convertNumber />
                                    </h:outputText> 

                                    <h:outputLabel value= "#{bundle.interestAmount}" /><h:outputLabel value= ":" />
                                    <h:outputText value="#{depositInfoBean.bilyet.interestAmount}" styleClass="numPos">
                                        <f:convertNumber />
                                    </h:outputText> 

                                    <h:outputLabel value= "#{bundle.taxAmount}" /><h:outputLabel value= ":" />
                                    <h:outputText value="#{depositInfoBean.bilyet.taxAmount}" styleClass="numPos">
                                        <f:convertNumber />
                                    </h:outputText> 

                                    <h:outputLabel value= "#{bundle.disbInterestOpt}" /><h:outputLabel value= ":" />
                                    <p:selectOneMenu style="width: 200px;" value="#{depositInfoBean.bilyet.disbInterestOpt}" label="#{bundle.disbInterestOpt}" disabled="true">
                                        <f:selectItems value="#{depositInfoBean.avblDisb}" />
                                    </p:selectOneMenu>
                                    
                                    <h:outputLabel style="padding: 0 15px 0 0;" value= "#{bundle.bilyetSavaccnt}" /><h:outputLabel value= ":" />
                                    <h:outputText  value="#{depositInfoBean.accntDest}" />

                                    <h:outputLabel value= "#{bundle.ownerAccnt}" /><h:outputLabel value= ":" />
                                    <h:outputText value="#{depositInfoBean.accntOwner}" />

                                    <h:outputLabel value= "#{bundle.disbOtherBankAccno}" /><h:outputLabel value= ":" />
                                    <h:outputText  value="#{depositInfoBean.bilyet.disbOtherBankAccno}" />

                                    <h:outputLabel value= "#{bundle.disbOtherBankName}" /><h:outputLabel value= ":" />
                                    <h:outputText  value="#{depositInfoBean.bilyet.disbOtherBankName}" />

                                    <h:outputLabel value= "#{bundle.disbOtherBankBranch}" /><h:outputLabel value= ":" />
                                    <h:outputText  value="#{depositInfoBean.bilyet.disbOtherBankBranch}" />

                                </h:panelGrid>
                            </p:panel>

                            <h:panelGrid columns="1" cellpadding="1" rowClasses="panelGridId" border="0" >
                                <p:panel header="#{bundle.cusledgen}">
                                    <p:outputPanel autoUpdate="true">
                                    <h:panelGrid columns="3" cellpadding="0" cellspacing="5">

                                        <h:outputLabel value= "#{bundle.globalName}" /><h:outputLabel value= ":" />
                                        <h:outputText style="padding: 0 75px 0 0;"  value="#{depositInfoBean.bilyet.customer.customerName}" />

                                        <h:outputLabel value= "#{bundle.aliasName}" /><h:outputLabel value= ":" />
                                        <h:outputText rendered="true" value="#{depositInfoBean.bilyet.customer.aliasName}" />

                                        <h:outputLabel value= "#{bundle.phone}" /><h:outputLabel value= ":" />
                                        <h:outputText value="#{depositInfoBean.bilyet.customer.phone}"/> 

                                        <h:outputLabel value= "#{bundle.mobilePhone}" /><h:outputLabel value= ":" />
                                        <h:outputText value="#{depositInfoBean.bilyet.customer.mobilePhone}"/>

                                        <h:outputLabel style="padding: 0 15px 0 0;"  value= "#{bundle.npwp}" /><h:outputLabel value= ":" />
                                        <h:outputText value="#{depositInfoBean.bilyet.customer.npwp}" />

                                        <h:outputLabel style="padding: 0 15px 0 0;"  value= "#{bundle.addressRes}" /><h:outputLabel value= ":" />
                                        <h:outputText value="#{depositInfoBean.bilyet.customer.idAddressLine1}" />

                                    </h:panelGrid>
                                    </p:outputPanel>
                                </p:panel>

                                <p:panel header="#{bundle.deproduct}" >
                                    <p:outputPanel autoUpdate="true">
                                    <h:panelGrid columns="3" cellpadding="0" cellspacing="5">
                                        <h:outputLabel value= "#{bundle.period}" /><h:outputLabel value= ":" />
                                        <h:outputText value="#{constantaBean.getDeptPeriodText(depositInfoBean.bilyet.deproduct.periodOpt)}" />

                                        <h:outputLabel value= "#{bundle.numOfPeriod}" /><h:outputLabel value= ":" />
                                        <h:outputText styleClass="alignNum" value="#{depositInfoBean.bilyet.deproduct.numOfPeriod}" />
                                    </h:panelGrid>
                                </p:outputPanel>        
                                </p:panel>
                            </h:panelGrid>

                        </h:panelGrid>
                    </h:panelGrid>
                    </p:tab>
                        <p:tab title="Simulasi Deposito">
                            <p:dataTable id="dtBilyetInfosim" scrollable="true" scrollHeight="350" value="#{depositInfoBean.bilyetSimulation}" var="simulasi" rowIndexVar="noUrut">
                            
                                <p:column style="width: 12px;">
                                    <f:facet name="header">No</f:facet>
                                    <h:outputText value="#{noUrut+1}" />
                                </p:column>

                                <p:column style="width: 50px;">
                                    <f:facet name="header">#{bundle.date}</f:facet>
                                    <h:outputText value="#{simulasi.bilyetDate}" />
                                </p:column>

                                <p:column style="width: 90px;">
                                    <f:facet name="header">Bunga</f:facet>
                                    <h:outputText value="#{simulasi.interestAmount}" styleClass="numPos" >
                                        <f:convertNumber />
                                    </h:outputText>
                                </p:column>

                                <p:column style="width: 80px;">
                                    <f:facet name="header">Pajak</f:facet>
                                    <h:outputText value="#{simulasi.taxAmount}" styleClass="numPos" >
                                        <f:convertNumber />
                                    </h:outputText>
                                </p:column>
                                
                                <p:columnGroup type="footer">  
                                    <p:row>  
                                        <p:column style="text-align:right" footerText="" />    
                                        <p:column style="text-align:right" footerText="Total:"/> 
                                        <p:column style="text-align:right" footerText="#{depositInfoBean.interestAmounts}" />    
                                        <p:column style="text-align:right" footerText="#{depositInfoBean.taxAmounts}" />    
                                    </p:row>
                                </p:columnGroup>
                                 

                            </p:dataTable>
                        </p:tab>
                    </p:tabView>
                    <h:panelGrid cellpadding="0" styleClass="pComBtnSTDR">
                        <f:facet name="footer">  
       <!--                     <p:commandButton value="#{bundle.approved}" icon="ui-icon-disk" actionListener="#{depositInfoBean.approve(true, loginBean.selectedUser.userId)}"
                                             update=":#{utilityBean.findClientId('dtDepositInfo')}"      
                                oncomplete="dlgDepositInfo.hide()"/>  -->
                            <p:commandButton value="#{bundle.btnClose}" oncomplete="dlgDepositInfo.hide()"  immediate="true"
                                icon="ui-icon-document" />
                        </f:facet>
                    </h:panelGrid>
                </h:form>
            </p:dialog>   
            
        </ui:composition>    
    </h:body>
</html>